package org.wishwork.api.aftersale.receive.query;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.wishwork.api.ExtendBase;

import java.util.List;

/**
 * @description: 实际收货查询
 * @author: WangYX
 * @create: 2022-04-12 15:31
 * @Version: 1.0.0
 **/
@Getter
@ToString
@EqualsAndHashCode
public class AfterSaleReceivedQueryRequest extends ExtendBase {

    /**
     * 非必填
     * 外部订单号列表
     */
    private List<String> soIds;

    /**
     * 非必填
     * ERP 内部订单号，唯一
     */
    private List<String> oIds;

    /**
     * 非必填
     * 退货店铺
     */
    private String shopId;

    /**
     * 日期类型，0:修改时间，1:创建日期，2:订单日期，4:实际出/入库时间
     */
    private Integer dateType;

    private AfterSaleReceivedQueryRequest(Integer pageIndex, Integer pageSize, String modifiedBegin, String modifiedEnd,
                                          List<String> soIds, List<String> oIds, String shopId, Integer dateType) {
        super(pageIndex, pageSize, modifiedBegin, modifiedEnd);
        this.dateType = dateType;
        this.oIds = oIds;
        this.shopId = shopId;
        this.soIds = soIds;
    }

    @Override
    public Builder toBuilder() {
        return new Builder()
                .pageIndex(this.pageIndex).pageSize(this.pageSize)
                .modifiedBegin(this.modifiedBegin).modifiedEnd(this.modifiedEnd)
                .dateType(this.dateType).shopId(this.shopId).soIds(this.soIds).oIds(this.oIds);
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder extends ExtendBase.Builder<Builder, AfterSaleReceivedQueryRequest> {

        private List<String> soIds;
        private List<String> oIds;
        private String shopId;
        private Integer dateType;

        @Override
        public Builder modifiedBegin(String modifiedBegin) {
            this.modifiedBegin = modifiedBegin;
            return this;
        }

        @Override
        public Builder modifiedEnd(String modifiedEnd) {
            this.modifiedEnd = modifiedEnd;
            return this;
        }

        @Override
        public Builder pageIndex(Integer pageIndex) {
            this.pageIndex = pageIndex;
            return this;
        }

        @Override
        public Builder pageSize(Integer pageSize) {
            this.pageSize = pageSize;
            return this;
        }

        public Builder soIds(List<String> soIds) {
            this.soIds = soIds;
            return this;
        }

        public Builder oIds(List<String> oIds) {
            this.oIds = oIds;
            return this;
        }

        public Builder shopId(String shopId) {
            this.shopId = shopId;
            return this;
        }

        public Builder dateType(Integer dateType) {
            this.dateType = dateType;
            return this;
        }

        @Override
        public AfterSaleReceivedQueryRequest build() {
            this.pageIndex = this.pageIndex == null ? 1 : this.pageIndex < 0 ? 1 : this.pageIndex;
            this.pageSize = this.pageSize == null ? 30 : this.pageSize < 0 ? 30 : this.pageSize;
            return new AfterSaleReceivedQueryRequest(this.pageIndex, this.pageSize, this.modifiedBegin, this.modifiedEnd,
                    this.soIds, this.oIds, this.shopId, this.dateType);
        }
    }


}
